package com.apesource.project02.controller;

import com.apesource.project02.pojo.MarathonEvent;
import com.apesource.project02.service.IMarathonEventService;
import com.apesource.project02.util.ResponseEntity;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @version 1.0
 * @auther:暮雪
 * @date:2025/9/19
 */


@RestController
@RequestMapping("/marathon-events")
public class MarathonEventController {
    @Autowired
    private IMarathonEventService marathonEventService;

    @GetMapping("/{eventId}")
    public ResponseEntity<MarathonEvent> getMarathonEventById(@PathVariable("eventId") int eventId) {

        ResponseEntity<MarathonEvent> eventsResponseEntity =marathonEventService.getMarathonEventById(eventId);

        return eventsResponseEntity;
    }

    @GetMapping
    public ResponseEntity<List<MarathonEvent>> getMarathonEvents() {

        return marathonEventService.getMarathonEvents();
    }

    @GetMapping("/upcoming")
    public ResponseEntity<List<MarathonEvent>> getUpcomingMarathonEvents() {

        return marathonEventService.getMarathonEventsByDate();
    }

}
